package com.neusoft.lohas.modules.ivm.entity.product;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.neusoft.lohas.common.persistence.IdEntity;
import com.neusoft.lohas.modules.ivm.entity.merchant.DeliveryMember;
import com.neusoft.lohas.modules.ivm.entity.merchant.Merchant;
import com.neusoft.lohas.modules.ivm.entity.purchase.Purchase;

/**
 * 商品入库记录Entity
 * 
 * @author Jackie.Liu
 * @version 2015-01-05
 */
@Entity
@Table(name = "ivm_product_inventory_detail")
@DynamicInsert
@DynamicUpdate
public class ProductInventoryDetail extends IdEntity<ProductInventoryDetail> {

	private static final long serialVersionUID = 1L;
	private Merchant merchant; // 所属商户
	private Product product; // 所属商品
	private DeliveryMember member; // 采购人员
	private int weight; // 采购量
	private int winWeight; //入库量
	private int lossWeight; // 损耗量
	private double amount; // 采购金额
	private Supplier supplier; // 采购供应商
	private Purchase purchase; //所属采购指令

	public ProductInventoryDetail() {
		super();
	}

	public ProductInventoryDetail(String id) {
		this();
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="merchant_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="归属商户不能为空")
	public Merchant getMerchant() {
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	@ManyToOne
	@JoinColumn(name = "product_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="所属商品不能为空")
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@ManyToOne
	@JoinColumn(name = "member_id")
	@NotFound(action = NotFoundAction.IGNORE)
	public DeliveryMember getMember() {
		return member;
	}

	public void setMember(DeliveryMember member) {
		this.member = member;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public int getWinWeight() {
		return winWeight;
	}

	public void setWinWeight(int winWeight) {
		this.winWeight = winWeight;
	}

	public int getLossWeight() {
		return lossWeight;
	}

	public void setLossWeight(int lossWeight) {
		this.lossWeight = lossWeight;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	@ManyToOne
	@JoinColumn(name="supplier_id")
	@NotFound(action = NotFoundAction.IGNORE)
	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	@OneToOne
	@JoinColumn(name = "purchase_id")
	@NotFound(action = NotFoundAction.IGNORE)
	public Purchase getPurchase() {
		return purchase;
	}

	public void setPurchase(Purchase purchase) {
		this.purchase = purchase;
	}

}
